package gao.xiaolei.dao;

import java.util.List;
import java.util.Optional;

import gao.xiaolei.entity.TestProject;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository("TestProjectDao")
public interface TestProjectDao extends JpaRepository<TestProject, String> {

    @Query("select system from TestProject where id=:id")
    public Optional<String> getSystem(@Param("id") String id);

    @Query("select name from TestProject where id=:id")
    public Optional<String> getName(@Param("id") String id);

    @Query("select groupId from TestProject where id=:id")
    public Optional<String> getGroupId(@Param("id") String id);

    @Query("select id,name from TestProject where groupId=:groupId")
    public List<Object []> queryIdAndNameByGroupId(@Param("groupId") String groupId);

    public List<TestProject> findAllByLeadingCadre(String leadingCadre);

    public List<TestProject> findAllByGroupId(String groupId);

    public Integer countByGroupId(String groupId);

    @Query("select id from TestProject where groupId=:groupId")
    public List<String> getIdsByGroupId(@Param("groupId") String groupId);

}
